package com.repair.project.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.repair.project.config.R;
import com.repair.project.entity.Material;
import com.repair.project.entity.User;
import com.repair.project.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.omg.PortableInterceptor.USER_EXCEPTION;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hz
 * @since 2021-01-12
 */
@RestController
@RequestMapping("/project/user")
public class UserController {

    @Autowired
    UserService userService;

    @ApiOperation("接口描述：判断是否首次登录")
    @GetMapping("isfirstlogin")
    public R isfirstlogin(@RequestParam(value = "openid")String  openid){

        List<User> user =userService.list(null);
        int isfirst=0;
        for(User str : user ){
            if(str.getOpenid()!=null){
                //判断是否首次登陆
                if(str.getOpenid().equals(openid)){
                    isfirst=1; }
            }
        }
       if(isfirst==1){
           //返回1    直接返回登录成功后的信息。
       }

        QueryWrapper<Material> objectQueryWrapper = new QueryWrapper<>();
        return R.ok().data("datalist",null);
    }



    @ApiOperation("接口描述：首次登录")
    @GetMapping("firstlogin")
    public R firstlogin(@RequestParam(value = "openid")String  openid,
                        @RequestParam(value = "type")String  type,
                        @RequestParam(value = "typeid")String  typeid
                        ){

        //  判断typeid在数据库里是否有？

        


        return R.ok().data("datalist",null);
    }

}




